<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="administration.Admin" %>
<%@ page import="java.util.List" %>
<%@ page import="administration.AdminManager" %>
<%@ page import="learninganalytics.Register"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>ControlPanel || Login</title>
<link rel="stylesheet" href="../styles/adminstyle.css" type="text/css" media="screen" title="default" />
<script type="text/javascript">

function check_fields(formname) 
{ 
    var returnval=false; 
    var msg=""; 

    if(formname.name.value=="") 
        msg+="You must fill your username!\n"; 
    if(formname.pwd.value=="") 
        msg+="You must fill your password\n"; 
    if(msg=="") 
    { 
        returnval=true; 
        return returnval; 
    } 
    else 
    { 
        alert(msg); 
        return returnval; 
    } 
} 

function submit_form(formname) 
{ 
    if(check_fields(formname)) 
    { 
        return true; 
    } 
    else 
    { 
        alert("Please, correct your data"); 
        return false; 
    } 
}
 </script>
</head>
<body>
<%	
	Register.init(); //objectify requires to register entity classes
	List<Admin> admins = AdminManager.findAll();
	Admin currAdmin = (Admin) session.getAttribute("currAdmin");
	if(admins.size() == 0){
		pageContext.include("initialisation.jsp");
	}
	else{
		if(currAdmin==null){
			
			pageContext.include("loginpanel.jsp");
		} else{ 
			
			pageContext.include("controlpanel.jsp");
		}
	}
	 %>
</body>
</html>